import Vue from "vue";
import VueRouter from "vue-router";
import index from "../views/index.vue";
import choose from "../views/choose.vue";
import create from "../views/create.vue";
import join from "../views/join.vue";
import host from "../views/host.vue";

// 解决ElementUI导航栏中的vue-router在3.0版本以上重复点菜单报错问题
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}

Vue.use(VueRouter)

const routes = [{
        path: "/",
        redirect: "/index"
    },
    {
        path: "/index",
        name: "index",
        component: index
    },
    {
        path: "/choose",
        name: "choose",
        component: choose
    },
    {
        path: "/create",
        name: "create",
        component: create
    },
    {
        path: "/join",
        name: "join",
        component: join
    },
    {
        path: "/host",
        name: "host",
        component: host
    }
];

const router = new VueRouter({
    mode: "history",
    base: './',
    routes
});

export default router;